All Questions
19 questions
1vote
2answers
52views
replace both filename and filename's content relying solely on pattern found on the name-of-the-file
I'd like to know if it's possible to replace both filename.ext and a matched pattern inside its content regarding a pattern founded on the filename itself using sed (and grep also, maybe?). Let me ...
1vote
1answer
329views
Find and replace a special pattern for all files in a folder
I have a series of files in a common bioinformatic format (FASTA) that consist of a string of: 1 special character ">", text as the sample name (length of the string varies, can include ...
0votes
1answer
114views
How do I find and replace something AFTER a specific term in a terminal output
I need to run blkid and copy a specific UUID after a specific known partition name. Then, I need to paste this into an exists config file, replacing a UUID that it's already there (parent_device_uuid)....
0votes
0answers
49views
Searching in one file and replacing it in another file
I am searching a substring in one file and replacing it with every occurrence of word "PASSWORD" in another file. Let say I have file1 with content: { "outcome" => "...
1vote
2answers
470views
Complicated search and replace in Vim or Sed
I have the following (yanked from my register to retain formatting, as it's probably the reason I'm here): <li><span>Concrete Patching (</span><span style="overflow: ...
1vote
1answer
159views
How to replace text between quotation marks with something from another file?
I have the following kind of text: $OU = 'or'; $DINHEIRO_CAIXA = 'Cash balance'; $PAGINA = 'Page'; $DE = 'from'; $ENVIAR = 'Send'; $PRINCIPAL = 'Main'; I've already got all the text within the single ...
0votes
1answer
2kviews
Simple Binary Replacement
I tried using bbe as below bbe -e 's/01110011/01111000/' test.txt All I'm trying to accomplish in this example is to read the file as if it's a binary file, and replacing the letter s with x. I'm ...
0votes
1answer
758views
I am not able to update a variable through sed command
I have assigned two variables but not able to update x=$(cat /scratch/env.properties | grep ConfigPath) y=$(ConfigPath=/scratch/a/b) then sed to replace ConfigPath in env.properties sed 's/$x/$y/' ...
1vote
4answers
227views
Replace text with values
I have two files that need to be merged into one. File 1 example: gene_1 578 gene_2 565 gene_3 3 gene_4 77 gene_5 8 gene_6 0 gene_7 45 gene_8 67 gene_9 0 gene_10 65 File2 example: COG0430 ...
3votes
2answers
3kviews
Replacing backslashes with forward slash within double quotes
I have some C source code which was originally developed on Windows. Now I want to work on it in Linux. There are tons of include directives that should be changed to Linux format, e.g: #include "..\...
9votes
6answers
47kviews
Replace all values in one column to 1
I have multiple text files containing 12 lines and 3 columns. Example: 2 6 0.74 42 6 0.58 80 6 0 112 6 0.24 132 6 1 216 6 0.7 342 6 ...
-1votes
1answer
1kviews
How do i create a sed script to prompt the user to replace a number in a file? [duplicate]
I'm new in Unix, and I'm learning about sed command. I need to write a very small script for searching a number in a file and replacing it. I tried doing grep, and than deleting the specific phone ...
0votes
1answer
1kviews
replace long text string (script with MANY special characters). sed, awk, grep
My site was hacked / infected. I replaced the url of the malicious link, but other elements in the malicious script are still making my site get blocked. Without inserting a hundred or so "escapes", ...
4votes
3answers
900views
Remove long string from files
Files on my server have been corrupted. I want to remove a 13000 character string from all PHP files containing it. The string looks like: ?php if(!isset($GLOBALS["\x61\156\x75\156\x61"])) { $ua=...
1vote
2answers
148views
find and replace a value in a line of text
I have a text file which contain only 1 line of text 1314:Battery:1.90:50:30 I'm trying to figure out if is there anyway to do a grep and sed to change the value 50 and 30 to the following 1314:...